package org.seefly.iprint.controller;

import org.seefly.iprint.entity.PageBean;
import org.seefly.iprint.entity.PhotoPrice;
import org.seefly.iprint.service.PriceService;
import org.seefly.iprint.vo.PriceVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class AdminPriceController {

    private PriceService priceService;
    @Value("${layui.status.success}")
    private String lauiTableStatus;

    public AdminPriceController(PriceService priceService) {
        this.priceService = priceService;
    }

    /**
     * 更新价格
     */
    @RequestMapping("/updatePrice")
    @ResponseBody
    public String updatePrice(PriceVo vo) {
        priceService.updatePrice(vo);
        return "OK";
    }
    
    
    /**
     *异步请求获取文档价格表
     */
    @SuppressWarnings("all")
    @RequestMapping("/getPriceTable")
    @ResponseBody
    public PageBean<PhotoPrice> getPhotoPrice(String title){
        List list = priceService.getPriceTable(title);
        PageBean pb = new PageBean<>();
        pb.setStatus(lauiTableStatus);
        pb.setList(list);
        return pb;
    }
    
    
}
